<?php

/**
 * @author Minh Luan
 * @copyright 2012
 */

include "../service/eventService.php";
if(isset($_POST["id"])){
    $id = $_POST["id"];
    
    $flash = $_FILES["flash"];
    $title_vn = $_POST["titleVn"];
    $title_en = $_POST["titleEn"];
    $content_en = $_POST["contentEn"];
    $content_vn = $_POST["contentVn"];
    $status = $_POST["status"];
    //Update Event
    updateEvent($id, $title_en, $title_vn, $content_en, $content_vn);
    //Update Event Status
    if($status == 1) updateEventStatus($id, 0);
    //Update Flash
        if($flash["type"] == "application/x-shockwave-flash" 
        ||$flash["type"] == "application/x-shockwave-flash2-preview" 
        ||$flash["type"] == "application/futuresplash" 
        ||$flash["type"] == "image/vnd.rn-realflash" )
          {
          if ($flash["type"]["error"] > 0)
            {
            echo "Error: " . $flash["type"]["error"] . "<br />";
            echo "<script>window.location.href='../admin/event-detail.php?id=$id&msg=4'</script>";
            }
          else
            {
            $flashResult = move_uploaded_file($flash["tmp_name"], "../images/event/".$id.".swf");
                if($flashResult){
                    updateEventFlash($id, $id.".swf");
                    echo "move va cap nhat db thanh cong";    
                }else{
                    echo "move faile";
                }
            }
          }else{
            echo "<script>window.location.href='../admin/event-detail.php?id=$id&msg=4'</script>";
          }
        echo "<script>window.location.href='../admin/event-detail.php?id=$id&msg=3'</script>";
}else{
    echo "<script>window.location.href='../admin/event-detail.php'</script>";
}

?>